import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.header import Header

# 发送方邮箱
msg_from = 'lbwhite@163.com'
# 邮箱为授权码
password = 'JTeD9pC4gemjwZx4'
# 收件方邮箱
msg_to = '3278566363@qq.com'
# 邮件主题
subject = '日报请查收'

# 创建邮件对象
msg = MIMEMultipart()
# 邮件主题
msg['Subject'] = Header(subject, 'utf-8')
# 邮件发送方
msg['From'] = msg_from
# 邮件接收方
msg['To'] = msg_to

msg.attach(MIMEText('今日日报:1. xxx','plain','utf-8'))


try:
    # 创建SMTP对象
    s = smtplib.SMTP_SSL("smtp.163.com", 465)
    # 登录邮箱
    s.login(msg_from, password)
    # 发送邮件
    s.sendmail(msg_from, msg_to, msg.as_string())
    print("发送成功")
except Exception as e:
    print(e)
    print("发送失败")